<?php

namespace Sbm;

class MasterList
{

	/**
	 * Список мастеров
	 * @var <array>
	 */
	private $list;

	function __construct()
	{
		
	}

	function SetList( $list )
	{
		$this->list = $list;
	}

	function get_masters_html( $master_list, $limit = 0, $delimiter = '<br/>' )
	{
		$masters_html = array();
		$masters_limit = 2;
		$count = 0;
		foreach ($master_list as $master)
		{
			$count++;
			if ( $count <= $limit )
			{
				$masters_html[] = sprintf("<a href='./?mod=%s&act=%s&id=%d'>%s</a>", 'master', 'edit', $master->id, $master->name);
			}
		}
		$html = "<div class='masters'>"
				. "<span class='short'>" . implode($delimiter, $masters_short) . "</span>"
				. "<span class='more'>...</span>"
				. "<span class='full'>" . implode($delimiter, $masters_full) . "</span>"
				. "</div>";
		return $html;
	}

}